package com.zh.zhbootcommon.domain;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Builder;
import lombok.Data;

import java.util.List;

/**
 * 描述: 统一分页
 *
 * @author: yanglin
 * @Date: 2021-10-28-20:17
 * @Version: 1.0
 */
@Data
public class DPage<T> {

    private long current;

    private long size;

    private long total;

    private List<T> list;

    @Builder
    public DPage(){}

    @Builder
    public DPage(long current, long size, long total, List<T> list) {
        this.current = current;
        this.size = size;
        this.total = total;
        this.list = list;
    }

    public static <T> DPage<T> to(IPage<T> iPage){
        return new DPage<T>(iPage.getCurrent(), iPage.getSize(), iPage.getTotal(), iPage.getRecords());
    }
}
